# data = {"type": "object", "properties": {"success": {"type": "boolean"}, "code": {"type": "integer"},
#                                   "message": {"type": "string"}},
#  "required": ["success", "code", "message"]}
# data1 = {"success"}

# import jsonschema
#
# schema = {"type": "object"}
# data = {1, 2, 3, 4}
# res = jsonschema.validate(instance=data, schema=schema)
# print(res)
# import jsonschema
# # 导包
# # 校验规则
# schema = {"type":"object",
#           "properties":{
#            "success":{"type":"boolean"},
#            "code":{"type":"integer"},
#            "message":{"type":"string"},
#            "money":{"type":"number"},
#            "address":{"type":"null"},
#            "data":{"type":"object",
#                    "properties":{
#                     "name":{"type":"string"},
#                     "age":{"type":"integer"},
#                     "height":{"type":"number"}
#                    }
#                    },
#            "luckyNumber":{"type":"array"}
#           }}
# # 校验数据
# data = {"success": True, "code": 10000, "message": "操作成功", "money": 6.66, "address": None,
#  "data": {"name": "tom","age":18,"height":1.78}, "luckyNumber": [6, 8, 9]}
# res = jsonschema.validate(instance=data,schema=schema)
# print(res)
import jsonschema

# data = {"success": True, "code": 10000, "message": "操作成功", "data": None}
# schema = {"type":"object",
#           "properties":{
#               "success":{"const":True},
#               "code":{"const":10000},
#               "message":{"const":"操作成功"},
#               "data":{"const":None}
#
#           }}
# res = jsonschema.validate(instance=data,schema=schema)
# print(res)
# data = {"message": "操作成功!", "mobile": "13800000002"}
import jsonschema
data = {"success":False,
        "code":10000,
        "message":"xxx登录成功",
        "data":{
            "age":20,
            "name":"lily",

        }
        }
# 校验数据
schema = {"type":"object",
          "properties":{
              "success":{"type":"boolean"},
              "code":{"type":10000},
              "message":{"pattern":"登录成功$",
              "data":{
                  "type":"object",
                  "properties":{
                      "name":{"type":"boolean"},
                      "age":{"type":20},
                  }


              }
                         }

          }}

